﻿using System;
using System.IO;

namespace MergeDir
{
    class MergeDirOptions : CommandArgument
    {
        [CommandArgumentElement("source", IsRequired = true, Help = "需要合并的原路径")]
        public string SourceDir { get; set; }

        [CommandArgumentElement("target", IsRequired = true, Help = "需要合并的目录路径")]
        public string TargetDir { get; set; }

        [CommandArgumentElement("diff", DefaultValue = "diff", Help = "不同文件拷贝路径")]
        public string DiffDir { get; set; }

        [CommandArgumentElement("ignore-diff", DefaultValue = false, Help = "忽略不一致的文件")]
        public bool IgnoreDiff { get; set; }

        public MergeDirOptions() : base("用于比较两个目录中的文件，并且将source中和target中不同的文件拷贝到diff目录")
        {
        }

        public bool CheckArgument()
        {
            if (!Directory.Exists(SourceDir))
            {
                Console.WriteLine("原路径不存在");
                return false;
            }

            if (!Directory.Exists(TargetDir))
            {
                Console.WriteLine("目标路径不存在");
                return false;
            }

            if (!Directory.Exists(DiffDir))
            {
                Directory.CreateDirectory(DiffDir);
            }

            return true;
        }
    }
}
